package edu.bu.grocerylist.dao;

import java.util.List;

import edu.bu.grocerylist.model.Category;
import edu.bu.grocerylist.model.GroceryList;
import edu.bu.grocerylist.model.GroceryListItem;
import edu.bu.grocerylist.model.Item;

/**
 * This interface defines the methods required to access a data object of a GroceryListItem in the database
 * @author donlanp
 *
 */
public interface IGroceryListItemDao {
	
	/**
	 * Saves a GroceryListItem to the database 
	 * @param item The item to save
	 * @return The item with an updated itemId reflecting the newly inserted row
	 */
	public GroceryListItem insertGroceryListItem(GroceryListItem item);
	
	/**
	 * Saves a GroceryListItem to the database 
	 * @param item The item to save
	 * @return The item with an updated itemId reflecting the newly updated row
	 */
	public GroceryListItem updateGroceryListItem(GroceryListItem item);
	
	/**
	 * Removes an item's row from the database
	 * @param item The item to delete
	 * @return true if deleted, false otherwise
	 */
	public boolean deleteGroceryListItem(GroceryListItem item);
	
	/**
	 * removes all items from grocery list
	 * @param grocerylist
	 */
	public void deleteAllGroceryListItemsFromList(GroceryList grocerylist);
	
	/**
	 * Retrieves all the items that are within a specific GroceryList
	 * @param listId The list to receive items of
	 * @return The List of GroceryListItems
	 */
	public List<GroceryListItem> getGroceryListItemsByListId(int listId);
	
	/**
	 * Retrieves a GroceryList item object based on the primary key of the table
	 * @param sample GroceryListITem object with listid, categoryid, and itemid
	 * @return The found groceryListItem, null if nothing found
	 */
	public GroceryListItem getGroceryListItemByPrimaryKey(GroceryListItem sample);
	
	/**
	 * Saves a new Category object to the database
	 * @param name The name of the category
	 * @param description The category's description
	 * @return The new category's id
	 */
	public Category saveNewCategory(Category category);
	
	/**
	 * Saves an item to the database
	 * @param name The name of the item (ex - apple, banana, etc)
	 * @return The new item's id
	 */
	public Item saveNewItem(Item item);
	
	/**
	 * Checks to see if this item exists in the database
	 * @param itemName The item to check
	 * @return true if it is in the database, false otherwise
	 */
	public boolean doesItemExist(String itemName);
	
	/**
	 * Checks to see if this category exists in the database
	 * @param categoryName The item to check
	 * @return true if it is in the database, false otherwise
	 */
	public boolean doesCategoryExist(String categoryName);
	
	
	/**
	 * Retrieves an category's id from the database
	 * @param name The category's name
	 * @return The category's id
	 */
	public Category getCategoryIdByName(String name);
	
	/**
	 * Retrieves an item's id from the database
	 * @param name The item's name
	 * @return The item's id
	 */
	public Item getItemIdByName(String name);

}
